package com.le.tester.leetcode;

/**
 * 描述：该花能不能种在花圃上
 */
public class CanPlaceFlowers {
    public boolean canPlaceFlowers(int[] flowerbed, int n) {
        //获取花圃的长度
        int length = flowerbed.length;
        int count = 0;

        for (int i = 0; i < length; i++) {
            if (flowerbed[i] == 0 && (i == length - 1 || flowerbed[i + 1] == 0) && (i == 0 || flowerbed[i - 1] == 0)) {
                flowerbed[i] = 1;
                count++;
            }
        }
        return count >= n;
    }
}
